<?php
namespace Admin\Controller;
use Think\Controller;
class CommonController extends Controller {
  
    function _initialize(){
          
          $sin = array("login","index","code","session"); //免登录的页面
        /*  print_r($_SESSION['username']);die;*/
         if(empty($_SESSION['username']) && !in_array(ACTION_NAME, $sin)){ 
           $this->error('请先登录',U('Admin/admin/login'),2);die;
         
        
         /*if(!in_array(ACTION_NAME, $sin)){
          $Auth = new \Think\Auth; //实例化验证方法
          $rul = Admin.'/'.CONTROLLER_NAME.'/'.ACTION_NAME;// 拼接当前路径 规则
          if(!$Auth->check($rul,$_SESSION['id'])){

               $this->error('没有权限','',2);die;
          }*/          
        }
            //优化index没有表

          if(!in_array(ACTION_NAME, $sin)){
              $this->Model = D(CONTROLLER_NAME); 
            }
          $User = D("nav");//实例化
           $datas = $User->where('pid=0')->select();//查询父级         
           $this->assign('datas',$datas); 
           
           $datass = $User->where('pid!=0')->select();//查询子级
           $this->assign('datass',$datass);

           $date = $User->select();
           $this->assign('date',$date);

         
      } 
}

